<!--[ include file="admin_header_menu.htm" ]-->
<div class="admin_content">
<a class="button" href="#"> เพิ่ม / แก้ไข หมวดหมู่หลัก</a>
<form id='form' class='form' action="<!--[pnmodurl modname='iCarrent' type='adminform' func='submit' ctrl='Province']-->" method="post">
<input type="hidden" name="form[id]" value="<!--[$_GET.id]-->" />
<input type="hidden" id='icon2d_field' name="form[icon]" value="<!--[$form.icon]-->" />
<table class="adminform">
  <tr>
    <td><label>ชื่อจังหวัด :</label></td>
    <td><input type="text" name="form[name]" value="<!--[$form.name]-->" title="Please enter category name" class="required"  /></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2"><hr></td>
  </tr>
  <tr>
    <td><label>สนามบิน :</label></td>
    <td>
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
      <script type="text/javascript">
      
         $(document).ready(function(){
        
            var counter = 2;
            
            $("#addAirport").click(function () {
              var newCounter =  counter-1;
              if(counter>10){
                alert("Only 10 textboxes allow");
                return false;
              }   
              //alert(newCounter+"::"+counter);
              

              
              if(counter==2){
                var newLine = "<br><br>";              
              }else{
                var newLine = "<br>";               
              }              
              
              var airportName = '<div id="AirportDiv'+ counter + '"><label>Airport Name #'+ counter + ' : </label>' +
              '<input type="text" name="form[airport]['+ counter + '][name]" id="textbox' + counter + '" value="" >';
              
              var airportCode = '<div id="AirportDiv'+ counter + '"><label>Airport Code #'+ counter + ' : </label>' +
              '<input type="text" name="form[airport]['+ counter + '][code]" id="textbox' + counter + '" value="" ></div>';
              
              
              $("#AirportDiv" + newCounter).append(newLine+airportName+"<br>"+airportCode);   
              
                     
              counter++;
            });          
            

            $("#removeAirport").click(function () {
              if(counter==2){
                  alert("No more textbox to remove");
                  return false;
              }   
              counter--;
          
              $("#AirportDiv" + counter).remove();
          });
          
          $("#getAirportValue").click(function () {
          
            var msg = '';
            for(i=1; i<counter; i++){
              msg += "\n Textbox #" + i + " : " + $('#textbox' + i).val();
            }
               alert(msg);
          });
          
        });
      </script>
      <div id='AirportGroup'>
        <div id="AirportDiv1">
          <input type="hidden" name="form[airport][1][prov_id]" id="textbox1" value="" >      
          <label>Airport Name #1 : </label><input type="text" name="form[airport][1][name]" id="textbox1" value="" ><br>
          <label>Airport Code #1 : </label><input type="text" name="form[airport][1][code]" id="textbox1" value="" >         
        </div>
      </div>
      <input type='button' value='Add Button' id='addAirport'>
      <input type='button' value='Remove Button' id='removeAirport'>
      <input type='button' value='Get TextBox Value' id='getAirportValue'>       
    </td>    
  </tr> 
  <tr>
    <td colspan="2"><hr></td>
  </tr>
  <tr>
    <td><label>สถานที่น่าสนใจ :</label></td>
    <td>
      <input type="text" name="form[airport_name]" value="<!--[$form.airport_name]-->" title="Please enter category name" class="required"  />
    </td>
  </tr>     
</table>
	<button name="button_submit" value='Submit' type="submit" class="button save">ตกลง</button>
	<button name="button_cancel" value='Cancel' type="submit" class="button flag">ยกเลิก</button>
</form>
</div>
<div>
</div>